<template>
  <a-layout
    style="position: relative; min-height: 100%; background:url(../../static/images/dt_bg.png) no-repeat center; background-size: 60%; padding-bottom:112px;"
  >
    <a-layout-header
      style="background: #001529; padding: 0 13%; box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35); -webkit-box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);"
    >
      <a-row>
        <a-col :span="8">
          <img src="../../static/images/login_icon.png" class="logo" />
          <span class="title">佳华物流集团 ERP</span>
        </a-col>
        <a-col :span="16" style="text-align: right; padding-right:12px; ">
          <login-user loc="entry" />
        </a-col>
      </a-row>
    </a-layout-header>
    <a-layout-content :style="{ padding: '0 13%', background: '#f0f2f5'}">
      <a-row :gutter="[30,30]" style="margin:0; padding-top:60px;">
        <a-col :span="24" class="modulesTitle">
          <h1>
            <span></span>集装箱业务
          </h1>
        </a-col>
        <a-col
          :span="6"
          v-for="item in listBusiness"
          :key="item.name"
          style=" border-radius:2px; -webkit-border-radius:2px;"
        >
          <a-card
            :bordered="false"
            :hoverable="true"
            @click="openModule(item.isPower, item.url, item.powerId)"
          >
            <a-row>
              <a-col>
                <img :src="getIconUri(item.icon)" class="index_icon" />
              </a-col>
              <a-col>
                <h2
                  style="font-size:1.2em; overflow:hidden; white-space: nowrap; text-overflow: ellipsis;"
                >{{item.name}}</h2>
                <p class="secondaryDesc">{{item.description}}</p>
              </a-col>
            </a-row>
          </a-card>
        </a-col>

        <a-col :span="24" class="modulesTitle" style="margin-top:40px;">
          <h1>
            <span></span>系统管理与设置
          </h1>
        </a-col>
        <a-col :span="6" v-for="item in listSystem" :key="item.name">
          <a-card
            :bordered="false"
            :hoverable="true"
            @click="openModule(item.isPower, item.url, item.powerId)"
          >
            <a-row>
              <a-col>
                <img :src="getIconUri(item.icon)" class="index_icon" />
              </a-col>
              <a-col>
                <h2
                  style="font-size:1.2em; overflow:hidden; white-space: nowrap; text-overflow: ellipsis; "
                >{{item.name}}</h2>
                <p class="secondaryDesc">{{item.description}}</p>
              </a-col>
            </a-row>
          </a-card>
        </a-col>
      </a-row>
    </a-layout-content>
    <a-layout-footer class="footer">
      <div class="links">
        Copyright
        <a-icon type="copyright" />2020
        <span>江苏佳华物流发展有限公司</span>
      </div>
      <div class="copyright">
        <p>江苏易船货科技有限公司 技术支持</p>
      </div>
    </a-layout-footer>
  </a-layout>
</template>

<script>
import {Layout, Icon} from 'ant-design-vue'
import LoginUser from '@/components/LoginUser'
import {queryFirstPower} from '@/api'

export default {
  name: 'entry',
  data () {
    return {
      listBusiness: [],
      listSystem: []
    }
  },
  methods: {
    openModule (isPower, moduleName, id) {
      if (isPower === 1) {
        window.open(moduleName, '_blank')
      } else {
        this.$notification['error']({
          message: '您没有该模块权限！'
        })
      }
    },
    getIconUri: (icon) => '../../static/images/' + icon + '.png'
  },
  components: {
    [Layout.name]: Layout,
    [Layout.Header.name]: Layout.Header,
    [Layout.Sider.name]: Layout.Sider,
    [Layout.Content.name]: Layout.Content,
    [Layout.Footer.name]: Layout.Footer,
    [Icon.name]: Icon,
    LoginUser
  },
  created () {
    // console.log('Create entry...')
    queryFirstPower().then(result => {
      this.listBusiness = result.data.listBusiness
      this.listSystem = result.data.listSystem
    })
  }
}
</script>

<style lang="less" scoped>
h1,
h2 {
  font-weight: 650;
  color: #333333;
}
.logo {
  height: 30px;
  float: left;
  margin-top: 17px;
  margin-right: 10px;
  padding-left: 12px;
}
.title {
  font-size: 26px;
  font-weight: bold;
  color: #fff;
}
.modulesTitle {
  padding: 0px 12px !important;
}
.modulesTitle h1 span {
  float: left;
  width: 5px;
  height: 18px;
  background: #1890ff;
  margin-top: 6.5px;
  margin-right: 10px;
  border-radius: 3px;
  -webkit-border-radius: 3px;
}
.index_icon {
  width: 65px;
  margin-right: 10px;
  float: left;
}

.secondaryDesc {
  display: -webkit-box;
  height: 42px;
  color: rgba(0, 0, 0, 0.45);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-overflow: ellipsis;
  overflow: hidden;
  -webkit-box-orient: vertical;
  word-wrap: break-word;
  word-break: break-all;
  margin-bottom: 0;
}

.footer {
  width: 100%;
  position: absolute;
  bottom: 0;
  left: 0;
  text-align: center;

  .links {
    margin-bottom: 8px;
    color: rgba(0, 0, 0, 0.45);

    a {
      color: rgba(0, 0, 0, 0.45);

      &:hover {
        color: rgba(0, 0, 0, 0.65);
      }

      &:not(:last-child) {
        margin-right: 40px;
      }
    }
  }
  .copyright {
    color: rgba(0, 0, 0, 0.45);
    font-size: 14px;
  }
}
</style>
